import 'package:flutter/material.dart';
import 'package:flutterone/config/configPages.dart';
import 'package:flutterone/page/home/home.dart';
import 'package:flutterone/page/login/Login.dart';
import 'package:flutterone/page/me/EditMe/editMeRemark.dart';
import 'unknowPage.dart';

class RouteNames {
  static const String login = '/login';
  static const String home = '/home';
  static const String editMeRemark = '/editMeRemark';
  static const String initialRoute = LDXHomeBody.routeName;
}

class LDXRoutes {
  // 使用不可变的 Map 存储路由映射
  static final Map<String, Widget Function(BuildContext)> routes = {
    RouteNames.login: (context) => const Login(),
    RouteNames.home: (context) => HomePage(),
    RouteNames.editMeRemark: (context) => const EditMeRemark(),
  };

  static Route<dynamic>? onGenerateRoute(RouteSettings settings) {
    if (settings.name == Login.routeName) {
      return MaterialPageRoute(
          fullscreenDialog: true,
          builder: (ctx) {
            return const Login();
          });
    }
    return null;
  }

  // 优化错误页面显示
  static Route<dynamic> onUnknownRoute(RouteSettings settings) {
    return MaterialPageRoute(
      builder: (context) => const Scaffold(body: unkonwnPage()),
    );
  }
}
